<?php require_once('../../core/import.php');?>
<?php User::Permission('USER_LIST'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <script type="text/javascript" src="../../scripts/import.js"></script>
    <script type="text/javascript" src="../../scripts/components/checkbox/import.checkbox.js"></script>
    <script type="text/javascript" src="../../scripts/components/zebra_table/import.zebra_table.js"></script>
    <script type="text/javascript" src="scripts/list.js"></script>
</head>

<body>
    <table width="98.5%" id="List" border="0" cellpadding="0" cellspacing="0" class="List">
    <thead>
    <tr>
        <th width="20%" align="left" valign="middle">&nbsp;用户名</th>
        <th width="20%" align="center" valign="middle">角色</th>
        <th width="25%" align="center" valign="middle">发布时间</th>
        <th width="25%" align="center" valign="middle">登录次数</th>
        <th width="9%" align="center" valign="middle">&nbsp;</th>
    </tr>
    </thead>    
    <tbody>
    <form id="Form1" name="Form1" method="post" >
    <?php
        #获取数据
		$User=new User(User::Session('Username'));
		if(strval($User->Data['RoleID'])!='0'){
			$Where=' where RoleID is null or RoleID > 0';
		}else{
			$Where=' where 1=1';	
		}
        $Data=DB::GetData('select ID,Username,RoleID,Datetime,Login_Count from management_user '.$Where.' order by ID desc limit ?,20');
        foreach($Data['Record'] as $Row)
        {
    ?>
    <tr>
        <td height="25" valign="middle">
            &nbsp;<a href="edit.php?id=<?php echo $Row['ID']; ?>"><?php echo $Row['Username']; ?></a>
        </td>
        <td height="25" align="center" valign="middle">
            <?php 
			if(strval($Row['RoleID'])=='0'){
				echo '最高权限';	
			}else{
				if($Row['RoleID']){
					$Roles=DB::GetRowByID('management_user_role',$Row['RoleID']);
					echo $Roles['Name'];
				}else{
					echo '无角色';
				}
			}
		 	
		 ?>
        </td>
        <td height="25" align="center" valign="middle">
            <?php echo $Row['Datetime'];?>
        </td>
        <td height="25" align="center" valign="middle">
            <?php echo $Row['Login_Count'];?>
        </td>
        <td height="25" align="center" valign="middle">
            <a href="edit.php?id=<?php echo $Row['ID']; ?>">编辑</a>
            <a href="javascript:mconfirm_delete('list.action.delete.php?id=<?php echo $Row['ID']?>');">删除</a>
        </td>
    </tr>
    <?php
        }
    ?>
    </form>
    </tbody>    
    <tfoot>
    <tr>
        <td height="25" colspan="5" align="center" valign="middle">
            <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="55%" align="left">
                <?php
                    PagerFactory::Create('Simple')->Display($Data);
                ?>
                </td>
            </tr>
            </table>    
         </td>
	</tr>
    </tfoot>    
    </table>
</body>
</html>